package com.zhoukx.prototype.improve;



/**
 * @ClassName Client
 * @Description: 原型模式  验证
 * @Author zhoukx
 * @Date 2020/8/6
 **/
public class Client {
    public static void main(String[] args) {
        System.out.println("原型模式完成对象的创建");
        Sheep sheep = new Sheep("tom", 1, "白色");
        sheep.setFriend(new Sheep("jack",2,"黄色"));
        System.out.println("sheep:"+sheep.toString()+sheep.getFriend());

        Sheep sheep1 = (Sheep)sheep.clone();
        System.out.println("sheep1:"+sheep1.toString()+sheep1.getFriend());

        Sheep sheep2 = (Sheep)sheep.clone();
        System.out.println("sheep2:"+sheep2.toString()+sheep2.getFriend());

        System.out.println(sheep.getFriend() == sheep1.getFriend());

    }
}
